Xbasic

INDEX.FIND Function

Syntax

P Find(P key|A keyvalue)

as P = .FIND( P key )

as P = .FIND( keyvalue as C )

Arguments

key

A dot variable that contains an element named "key", which has been set to the search value.

keyvalue

A search value to compare to entries in the index.

Description

Find a key in the index - returns the key found.

Discussion

The .FIND() method finds a key in the index and returns a pointer to the nearest Key_Value found. The key has two properties: key and record, as illustrated below.

Example

In both the following examples, the .FIND() method finds the nearest matching key and returns the record number.

dim t as P
dim i as P
dim x as P
t = table.open("customer")
i = t.index_primary_put("Lastname")
x = i.find("jones")
? x.key
= "Jones              Smart Stuffing                "
? x.record
= 43.000000
dim q as P
dim q.key as C
q.key = "Edward"
? i.find(q)
= Key = "Feld                                              "
Record = 5.000000

See Also